function reverseDigits(number)
{
    var arr = new Array(number.toString().length);

    for (var i = 0; i < arr.length; i++)
    {
        arr[i] = number.toString()[arr.length - 1 - i];
    }

    return parseInt(arr.join(''));
}

console.log(reverseDigits(1234));